//index.js
var qcloud = require('../../vendor/wafer2-client-sdk/index')
var config = require('../../config')
var util = require('../../utils/util.js')

Page({
    data: {
        userInfo: {},
        logged: false,
        takeSession: false,
        requestResult: '',
        avatarUrl: ' ',
        nickName: ' ' 

        //采用同步的话，在刚启动小程序的时候，会出现头像缺失的情况
        //若使用异步的话，则不会出现这种情况
        // avatarUrl: wx.getStorageSync('avatarUrl'),
        // nickName: wx.getStorageSync('nickName')
    },
    
    //使用异步的形式读取缓存的数据
    onLoad: function (options) {
      var that = this
      wx.getStorage({
        key: 'avatarUrl',
        success: function(res) {
          that.setData({
            avatarUrl : res.data
          })
          console.log(that.data.avatarUrl)    
        }
      })
      wx.getStorage({
        key: 'nickName',
        success: function (res) {
          that.setData({
            nickName: res.data
          })
          console.log(that.data.nickName)
        }
      })



    },

})
